home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Graphics / GraphicsWorkshop / Source / Converters / tif.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-05-24  |  7.5 KB  |  200 lines

  1. /*
  2.  * TIFF Converter
  3.  * 
  4.  * Supports: All methods
  5.  *
  6.  * Reads and writes mulitple TIFF (Tagged Image File Format) pictures from specified
  7.  * input/output streams.
  8.  */
  9.  
  10. #ifndef __TIFFCONVERT__
  11. #define __TIFFCONVERT__
  12.  
  13. #import <Converter.h>
  14.  
  15. #define TIFF_COMPRESS_METHOD    "TiffCompressionMethod"
  16. #define TIFF_COMPRESS_RATIO        "TiffCompressionRatio"
  17.  
  18. #define CONVERT_ERR_NONE        0
  19. #define CONVERT_ERR_WARNING    1
  20. #define CONVERT_ERR_FATAL        2
  21.  
  22. #define ERROR_NO_ERROR            0
  23. #define ERROR_UNABLE_TO_OPEN    1
  24. #define ERROR_PERMISSION_DENIED    2
  25. #define ERROR_BAD_FORMAT        3
  26. #define ERROR_TRUNCATED_FILE    4
  27. #define ERROR_NEEDSWINDOWSERV    5
  28. #define ERROR_UNABLETOLINK        6
  29. #define ERROR_UNKNOWN            7
  30.  
  31. @interface TIF : Converter
  32. {
  33. }
  34.  
  35. /*
  36.  * Initializes the object.
  37.  * Assumes:     Nothing
  38.  * Returns:    self
  39.  * Results:    Sets up default compression and compression ratio parameters. 
  40.  *            That is, TiffCompressMethod is NX_TIFF_COMPRESSION_NONE, and
  41.  *            TiffCompressionRatio is 10.
  42.  */
  43. - init;
  44.  
  45. /*
  46.  * Frees anything used by the instance.
  47.  * Assumes:    Object is instantiated.
  48.  * Results:     It is no longer valid to message the object.
  49.  */
  50. - free;
  51.  
  52. /*
  53.  * Reads the tiff from stream. This can read any TIFF format that NXBitmapImageRep can.
  54.  * Assumes:    The object has been instantiated, stream is an valid stream opened for at least
  55.  *            reading. Sender is the id of whatever object is calling the converter. 
  56.  * Returns:    id of an NXBitmapImageRep or nil if the image was unable to be read.
  57.  */
  58. - readFromStream: (NXStream *)stream from: sender;
  59.  
  60. /*
  61.  * Write the image id to stream.
  62.  * Assumes:    Object has been instantiated. At times, it's best to have used a call to the
  63.  *             save panel first, since this can set internal variables, but it's not necessary.
  64.  *            stream should be a valid NXStream opened for at least writing. Sender should
  65.  *            be the id of the caller. id is a NXBitmapImageRep, or something that responds
  66.  *            to all the message of the NXBitmapImageRep.
  67.  * Returns:    YES if the image was sucessfully writing, otherwise it returns NO.
  68.  */
  69. - (BOOL)write: (id)image toStream: (NXStream *)stream from: sender;
  70.  
  71. /*
  72.  * Similar to readFromStream but will read multiple TIFF's from a stream, when present.
  73.  * Assumes:     Object instantiated. stream valid for reading. sender is id of caller.
  74.  * Returns:    id of an NXImage or nil if unable to read the image. It should return a single
  75.  *            image in the least, even for formats that don't support multiple images.
  76.  */
  77. - readAllFromStream: (NXStream *)stream from: sender;
  78.  
  79. /*
  80.  * Reverses the process of read all.
  81.  * Assumes:     Object instantiates. id is to an NXImage or something that responds to all of
  82.  *            NXImage's methods. stream is valid for writing. This should always attempt
  83.  *            to write at least one image to disk (the first usually) even for formats that 
  84.  *            don't support multiple images.
  85.  * Returns:    YES if the image is sucessfully written to disk.
  86.  */
  87. - (BOOL)writeAll: (id)image toStream: (NXStream *)stream;
  88.  
  89. /*
  90.  * Creates and lays out a custom view that allows the user to set compression method
  91.  * and ratio. 
  92.  * Assumes:     Object instantiated and the window server is running. width should be the
  93.  *            maximum width the custom view can be.
  94.  * Returns:    id of a parent view or nil if this object doesn't use one.
  95.  */
  96. - customSaveView: (int)width;
  97.  
  98. /*
  99.  * This is very similar to customSaveView, however, it is used to set parameters for
  100.  * the run time loading of images. This object does not support input custom views.
  101.  * Assumes:     Object instantiated and the window server is running. width should be the
  102.  *            maximum width the custom view can be.
  103.  * Returns:    id of a parent view or nil if this object doesn't use one.
  104.  */
  105. - customOpenView: (int)width;
  106.  
  107. /*
  108.  * Returns the name of the file format.
  109.  * Assumes:     Object has been instantiated.
  110.  * Returns:    A pointer to a string. The caller should always use something like strcpy to
  111.  *            get a copy of the string, since it's life is only guaranteed for the life of the
  112.  *            object. The returned string is "Tagged Image File Format (TIFF)".
  113.  */
  114. - (char *)getFormatName;
  115.  
  116. /*
  117.  * This can be used to set the compression method and ratio. It will respond to both
  118.  * TIFF_COMPRESS_METHOD and TIFF_COMPRESS_RATIO. With 
  119.  * TIFF_COMPRESS_METHOD, the pointer should point to and int definded as one
  120.  * of the compression methods in appkit/tiff.h. With TIFF_COMPRESS_RATIO the
  121.  * pointer should point to a float ranging from 1 to 255. 1 is little compress 255 too much.
  122.  * Assumes:    The converter is instantiated, parameter is a NULL terminated character
  123.  *            string, and ptr is a pointer to the data type. This is determined by patameter.
  124.  * Returns:    YES if the value was set, NO if the setting failed for any reason.
  125.  */
  126.  - (BOOL)setCustomParameter: (const char *)parameter withValue: (void *)ptr;
  127.  
  128. /*
  129.  * Returns values of the custom paramters. See discussion in setCustomParameter for
  130.  * parameter types.
  131.  * Assumes:     The converter is instantiated and parameter is a NULL terminater char-
  132.  *            acter string.
  133.  * Returns:    A pointer to the parameter (type depends on return value) or nil if the
  134.  *            parameter is not understood. Returned values should be copied.
  135.  */
  136.  - (void *)getCustomParameter: (const char *)parameter;
  137.  
  138.  /*
  139.   * Returns a string with copyright information, name of the author, where the author
  140.   * can be reached, etc. This should only be a couple of lines, so keep it short and 
  141.   * sweet. An example might be:
  142.   * "My Image Format Converter\nby Joe Programmer\nCopyright R'N'R Software\n ...
  143.   * ... email bugs to jprogramm@system.there.edu"
  144.   * Assumes:     Converter linked and instantiated.
  145.   * Returns:    A pointer to a null terminated string. This string must be non volatile for
  146.   *             the life of the converter. Ie, as long as the programmer keeps a converter
  147.   *            linked, the pointer should be valid.
  148.   */
  149.  - (char *)copyrightNotice;
  150.  
  151.  /*
  152.   * Returns the current error state of the converter.
  153.   * Assumes:     Converter has been instantiated.
  154.   * Returns:    0 = CONVERT_ERR_NONE         Signals no error
  155.   *            1 = CONVERT_ERR_WARNING   Signals action taken, but not one expected.
  156.   *            2 = CONVERT_ERR_FATAL          Signals no action taken.
  157.   */
  158.  - (int)errorState;
  159.  
  160.  /*
  161.   * Returns an int describing the current error message.
  162.   * Assumes:    Converter instantiated.
  163.   * Returns:    An int describing the error type. See defines for integers returned.
  164.   */
  165.  - (int)errorMessage;
  166.  
  167.  /*
  168.   * This provides support for non standard error messages. It's preferable for programmers
  169.   * to avoid this message, but in special cases where you need to express something unique,
  170.   * it is appropiate. Just remember, that the use of this message disables multilingual
  171.   * support.
  172.   * Assumes:    Converter Instantiated
  173.   * Returns:    NULL terminated string describing the error.
  174.   */
  175.  - (char *)errorStringMessage;
  176.  
  177.  /*
  178.   * This method returns YES if the converter requires the window server. Ideally, converters
  179.   * should not depend on the window server, but sometimes this cannot be avoided. For 
  180.   * example, a programmer wouldn't be expect to write a PostScript interpreter just to read
  181.   * in eps files. Note, however, that returning YES will result in the converter not working
  182.   * with command line versions of applications.
  183.   * Assumes:    Converter Instantiated
  184.   * Returns:    YES is window server is needed, NO otherwise.
  185.   */
  186. - (BOOL)needsWindowServer;
  187.  
  188. /*
  189.  * Returns a string in the form <major version>.<minor version>. This is used by
  190.  * the calling program to see what level or protocol the object will respond to.
  191.  * Assumes:    Converter instantiated.
  192.  * Returns:     A null terminated string in the form <major version>.<minor version>.
  193.  *            For example, 1.0.
  194.  */
  195. - (char *)protocolVersion;
  196.  
  197. @end
  198.  
  199. #endif
  200.